/**
 * Validation Add contact form
 * @returns {Boolean}
 */
function validateFormAdd(){
	var firstName = $("#firstname");	
	var fnCheck = $("#lbCheckFirstName");
	var lastName = $("#lastname");
	var lnCheck = $("#lbCheckLastName");
	var email = $("#email");
	var emailCheck = $("#lbCheckEmail");
	var street = $("#street");
	var city = $("#city");
	var zip = $("#zip");
	var country = $("#country");
	var phone1 = $("#phone1");
	var phone2 = $("#phone2");
	var phone3 = $("#phone3");
	var streetCheck = $("#lbCheckStreet");
	var cityCheck = $("#lbCheckCity");
	var zipCheck = $("#lbCheckZip");
	var countryCheck = $("#lbCheckCountry");
	var phoneCheck = $("#lbCheckPhone");
	if(firstName.val() == "" | email.val()== "" | lastName.val() == "" 
		| street.val() == "" | city.val() == "" | zip.val() == "" 
			| country.val() == " " | (phone1.val()=="" & phone2.val()=="" & phone3.val()=="")){
		if(firstName.val() == "")
			fnCheck.text("*This field must not be empty!");
		else
			fnCheck.text("");
		if(email.val()== "")
			emailCheck.text("*This field must not be empty!");
		else
			emailCheck.text("");
		if(lastName.val()=="")
			lnCheck.text("*This field must not be empty!");
		else
			lnCheck.text("");
		if(street.val()=="")
			streetCheck.text("*This field must not be empty!");
		else
			streetCheck.text("");
		if(city.val()=="")
			cityCheck.text("*This field must not be empty!");
		else
			cityCheck.text("");
		if(zip.val()=="")
			zipCheck.text("*This field must not be empty!");
		else
			zipCheck.text("");
		if(country.val()==" ")
			countryCheck.text("*Please select your country!");
		else
			countryCheck.text("");
		if(phone1.val()=="" & phone2.val()=="" & phone3.val()=="")
			phoneCheck.text("*This field must not be empty!");
		else
			phoneCheck.text("");
		return false;
	} else {
		fnCheck.text("");
		emailCheck.text("");
		lnCheck.text("");
		streetCheck.text("");
		cityCheck.text("");
		zipCheck.text("");
		countryCheck.text("");
		phoneCheck.text("");
		return true;
	}
};

/**
 * Validation login form
 * @returns {Boolean}
 */
function validateFormWelcome(){
	var login = $("#username");	
	var loginCheck = $("#lbCheckLogin");
	var pass = $("#password");
	var passCheck = $("#lbCheckPass");
	if(login.val() == "" | pass.val() == ""){
		if(login.val() == "")
			loginCheck.text("*This field must not be empty!");
		else
			fnCheck.text("");
		if(pass.val()=="")
			passCheck.text("*This field must not be empty!");
		else
			passCheck.text("");
		return false;
	} else {
		loginCheck.text("");
		passCheck.text("");
		return true;
	}
};

function validateNullID(){
	var id = $("#id_contact");
	var idCheck = $("#lbCheckID");
	if(id.val()== ""){
		idCheck.text("*ID must not be null!");
		return false;
	}else{
		idCheck.text("");
		return true;
	}
};

function createContactOrEnt(){
	var contact = $("input[name=creationtype]:checked");
	var siret = $("#siret");
	var siretCheck = $("#lbCheckSiret");
	var lbsiret = $("#lbsiret");
	if(contact.val() == "Contact"){
		siret.hide();
		siretCheck.hide();
		lbsiret.hide();
	}else{
		siret.show();
		siretCheck.show();
		lbsiret.show();
	}
}